package segment_tree


func NewCheckSegment(arr []int) CheckSegment {
	copyA := make([]int, len(arr))
	copy(copyA, arr)
	return CheckSegment{
		arr: copyA,
	}
}

type CheckSegment struct {
	arr []int
}

func (c *CheckSegment) Add(L, R, num int) {
	for i:=L; i<=R; i++ {
		c.arr[i] += num
	}
}

func (c *CheckSegment) Update(L, R, num int) {
	for i:=L; i<=R; i++ {
		c.arr[i] = num
	}
}

func (c *CheckSegment) Query(L, R int) int {
	var ans int
	for i:=L; i<=R; i++ {
		ans += c.arr[i]
	}
	return ans
}